package com.cskaoyan.market.exception;

import com.cskaoyan.market.util.ResponseUtil;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/20 23:48
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(ParameterException.class)
    public Object exp1(Exception e){
        return ResponseUtil.fail(401,e.getMessage());
    }

    @ExceptionHandler(AuthorizationException.class)
    public Object exp2(Exception e){
        System.out.println("authorization");
        return ResponseUtil.fail(501,"请登录");}

    @ExceptionHandler(GoodsCountException.class)
    public Object exp3(Exception e){return ResponseUtil.ok(0);}
}
